using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.GoogleMaps;
using Android.Graphics.Drawables;
using Android.Graphics;
using Android.Util;


namespace Moogle
{
    /// <summary>
    /// Fill Activity class.  This activity provides the user with the ability to search for pharmacies 
    /// where their prescriptions can be filled or their over the counter (OTC) medication can be purchased.
    /// It's target consumer is the Program class.
    /// </summary>
    [Activity(MainLauncher = false, Theme="@android:style/Theme.NoTitleBar")]
    [IntentFilter(new[] { Intent.ActionMain })]
    public class ActivityFill : MapActivity
    {
        #region Local Memory
        private const string __C_TAG = "ActivityFill";
        MyLocationOverlay __M_myLocationOverlay;
        MapView __M_mapView;

        #endregion
        #region On Create Control Function
        /// <summary>
        /// Class (or Activity) entry point.
        /// </summary>
        /// <param name="bundle">Android.OS.Bundle object instance that can be used to pass data to activity at startup.</param>
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Log.Info(__C_TAG, "OnCreate started.");

            try
            {
                /// Load the screen layout
                this.SetContentView(Resource.Layout.fill);
                __M_mapView = FindViewById<MapView>(Resource.Id.mapview);
                /// Set the properties of the map
                __M_mapView.Clickable = true;
                __M_mapView.Traffic = false;
                __M_mapView.Satellite = false;
                __M_mapView.Controller.SetZoom(10);
                /// Add an overlay representing the device's current location
                __M_myLocationOverlay = new MyLocationOverlay(this, __M_mapView);
                __M_mapView.Overlays.Add(__M_myLocationOverlay);
                __M_myLocationOverlay.RunOnFirstFix(() =>
                {
                    __M_mapView.Controller.AnimateTo(__M_myLocationOverlay.MyLocation);
                });
                __M_mapView.Overlays.Add(__M_myLocationOverlay);
            } // end try
            catch (SystemException err)
            {
                Log.Error(__C_TAG, err.Message);
            } // end catch
            finally
            {
                Log.Info(__C_TAG, "OnCreate ended.");
            } // end finally
        }
        #endregion
        #region Base Class Overrides
        protected override bool IsRouteDisplayed
        {
            get { return false; }
        }
        protected override void OnResume()
        {
            base.OnResume();

            __M_myLocationOverlay.EnableMyLocation();
        }

        protected override void OnPause()
        {
            base.OnPause();

            __M_myLocationOverlay.DisableMyLocation();
        }
        #endregion
    }

   

}